#ifndef __I264E_CLIOPT_H__
#define __I264E_CLIOPT_H__

#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <pthread.h>

#include <i264e.h>

typedef void *hnd_t;
typedef struct cli_input_t cli_input_t;

typedef enum {
	SENSOR_OV9712 = 0,
	SENSOR_OV9732,
	SENSOR_OV9750,
	SENSOR_AR0141,
	SENSOR_GC1004,
	SENSOR_JXH42,
	SENSOR_SC1035,
} sensor_type_t;


typedef struct cli_opt {
	int			i_csp;
	int			b_progress;
	/*0:raw 1:v4l2*/
	int			input;
	sensor_type_t	sensor_type;
	int			b_thread_input;
	char		*input_file_name;
	char		*output_file_name;
	FILE		*input_file;
	FILE		*output_file;
	pthread_t	output_tid;
	int			totalframe;
	int			image_width;
	int			image_height;
	hnd_t		hin;
	cli_input_t *cli_input;
	/*used for thread input*/
	hnd_t		hthread;
	/*read frame num*/
	int			i_frame;
	uint8_t **nal_buffer;
	int			read_cnt;
	int			pic_cnt;
	int			reuse_cnt;

	/* buf managememt */
	/* must be vitural addr */
	bool b_use_phy;
	void *(*ckmalloc)(int index, int size, int align);
	void (*ckfree)(int index, void *);
	intptr_t (*ckvirt_to_phys)(intptr_t vaddr);
	intptr_t (*ckphys_to_virt)(intptr_t paddr);
} cli_opt_t;

typedef struct save_info {
	i264e_t			*h;
	volatile int	*ctl;
	cli_opt_t		*opt;
	i264e_param_t	*param;
} save_info_t;

struct cli_input_t
{
	int (*open_file)(char *filename, cli_opt_t *opt);
	int (*picture_alloc)(i264e_pic_t *pic, cli_opt_t *opt);
	int (*read_frame)(i264e_pic_t *pic, cli_opt_t *opt);
	int (*release_frame)(i264e_pic_t *pic, cli_opt_t *opt);
	void (*picture_clean)(i264e_pic_t *pic, cli_opt_t *opt);
	int (*close_file)(cli_opt_t *opt);
};

extern const	cli_input_t cli_input_raw;
extern const	cli_input_t cli_input_v4l2;
extern			cli_input_t thread_input;

#endif
